/**
 * 
 */
package Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bean.Product;
import service.productService;
import util.BaseServlet;


public class ProductServlet extends BaseServlet{
	private productService productservice = new productService();
	
	public void queryproduct(HttpServletRequest request,HttpServletResponse response) {
		HttpSession session = request.getSession();
		String bid = request.getParameter("bid");
		Product product = productservice.queryProductService(bid);
		session.setAttribute("product", product);
		try {
			response.sendRedirect(request.getContextPath() + "/displayproduct.jsp");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void querypage(HttpServletRequest request,HttpServletResponse response) {
		HttpSession session = request.getSession();
		String stringPage = request.getParameter("page");
		Integer intPage = Integer.parseInt(stringPage);
		Product[] product = null;
		product = productservice.queryPageService(intPage); 
		session.setAttribute("productinfo", product);
		session.setAttribute("currentPage1", intPage);
		
		try {
			response.sendRedirect(request.getContextPath() + "/index.jsp");
			
		} catch (IOException e) {
			
			e.printStackTrace();
		}
		
		
	}
}
